package java_thinking.unit_18_IO._18_10;

import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.SortedMap;

import static common.util.Print.print;
import static common.util.Print.printnb;

/**
 * @Desc:   Charset：提供了把数据编码成多种不同类型的字符集的工具
 * @author: cww
 * @DateTime: 2019/5/17 18:39
 */

public class AvailableCharSets {
    public static void main(String[] args) {
        SortedMap<String, Charset> charSets = Charset.availableCharsets();
        Iterator<String> it = charSets.keySet().iterator();
        while (it.hasNext()) {
            String csName = it.next();
            printnb(csName);
            Iterator aliases = charSets.get(csName).aliases().iterator();
            if (aliases.hasNext()) {
                printnb(": ");
            }
            while (aliases.hasNext()) {
                printnb(aliases.next());
                if (aliases.hasNext()) {
                    printnb(", ");
                }
            }
            print();
        }
    }
}
